<@_sysDept id=id>
	<#assign a=object/>
	<#if (object.parentId)??><#assign parentId=object.parentId/></#if>
	<#if (object.userId)??><#assign userId=object.userId/></#if>
</@_sysDept>
<@_sysUser id=userId><#assign user=object/></@_sysUser>
<@_sysDept id=parentId!><#assign parentName=(object.name)!/></@_sysDept>
<form method="post" action="sysDept/save.do?callbackType=closeCurrent&navTabId=sysDept/list" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
	<input name="id" type="hidden" value="${id!}" />
	<div class="formBar">
		<ul>
			<li><button type="submit" class="buttonActive">保存</button></li>
			<li><button type="button" class="button close">关闭</button></li>
		</ul>
	</div>
	<div class="pageFormContent" layoutH="56">
		<dl class="nowrap">
			<dt>父部门:</dt>
			<dd>
				<input name="parentId" type="hidden" value="${parentId!}"/>
				<input name="parentName" readonly="readonly" type="text" size="10" value="${(parentName)!}"/>
				<a class="btnLook" href="sysDept/lookup.html" lookupGroup="">选择</a>
			</dd>
		</dl>
		<dl class="nowrap">
			<dt>名称:</dt>
			<dd><input class="required" name="name" type="text" size="30" value="${(a.name)!}"/></dd>
		</dl>
		<dl class="nowrap">
			<dt>描述:</dt>
			<dd><textarea name="description" maxlength="300" style="width: 100%;" rows="5">${(a.description)!}</textarea></dd>
		</dl>
		<dl class="nowrap">
			<dt>负责人:</dt>
			<dd>
				<input name="userId" value="${userId!}" type="hidden"/>
				<input name="nickName" readonly="readonly" size="10" value="${(user.nickName)!}" type="text"/>
				<a class="btnLook" href="sysUser/lookup.html" width="920" warn="请选择用户" lookupGroup="">选择用户</a>	
			</dd>
		</dl>
		<dl>
			<dt>拥有全部分类:</dt>
			<dd><input name="ownsAllCategory" type="checkbox" onclick="if($(this).is(':checked')){$('.ownsAllCategory',navTab.getCurrentPanel()).hide();}else{$('.ownsAllCategory',navTab.getCurrentPanel()).show();}"/></dd>
		</dl>
		<dl class="nowrap">
			<dt>拥有全部页面:</dt>
			<dd><input name="ownsAllPage" type="checkbox" onclick="if($(this).is(':checked')){$('.ownsAllPage',navTab.getCurrentPanel()).hide();}else{$('.ownsAllPage',navTab.getCurrentPanel()).show();}"/></dd>
		</dl>
<#macro categoryTree parentId=''>
	<@_categoryList parentId=parentId>
		<#list page.list as a>
			<li>
				<a tname="categoryIds" tvalue="${a.id}">${a.name}</a>
			<#if a.childIds?has_content>
				<ul>
					<@categoryTree a.id/>
				</ul>
			</#if>
			</li>
		<#else>
			<li><a>空目录</a></li>
		</#list>
	</@_categoryList>
</#macro>
		<fieldset class="ownsAllCategory">
			<legend><i class="icon-folder-open icon-large"></i> 分类授权</legend>
			<ul class="tree treeFolder treeCheck expand">
				<li>
					<a href="javascript:;" onclick="return false;">所有分类</a>
					<ul><@categoryTree/></ul>
				</li>
			</ul>
		</fieldset>
<#macro pageTree filepath=''>
	<@_templateList path=filepath>
		<@_metadata dir=filepath><#local metaDataMap=object/></@_metadata>
		<#list list as a>
			<#if 'ftl'!=a.fileName>
				<li>
					<#local path=filepath+'/'+a.fileName>
					<a tname="pages" tvalue="${path}">${a.fileName} ${(metaDataMap[a.fileName].alias)?has_content?then('('+metaDataMap[a.fileName].alias+')','')}</a>
					<#if a.directory>
					<ul>
						<@pageTree path/>
					</ul>
					</#if>
				</li>
			</#if>
		<#else>
			<li><a>空目录</a></li>
		</#list>
	</@_templateList>
</#macro>
		<fieldset class="ownsAllPage">
			<legend>页面授权</legend>
			<ul class="tree treeFolder treeCheck expand">
				<li>
					<a href="javascript:;" onclick="return false;">所有页面</a>
					<ul><@pageTree/></ul>
				</li>
			</ul>
		</fieldset>
<#if a??>
<script>
	<#if a.ownsAllPage>
	$('input[name=ownsAllPage]',navTab.getCurrentPanel()).click();
	</#if>
	<@_sysDeptPageList deptId=a.id>
		<#list page.list as a>
	$('.ownsAllPage .tree li a[tname=pages][tvalue="${a.id.page?js_string}"]',navTab.getCurrentPanel()).prop('checked',true);
		</#list>
	</@_sysDeptPageList>
	<#if a.ownsAllCategory>
	$('input[name=ownsAllCategory]',navTab.getCurrentPanel()).click();
	</#if>
	<@_sysDeptCategoryList deptId=a.id>
		<#list page.list as a>
	$('.ownsAllCategory .tree li a[tname=categoryIds][tvalue=${a.id.categoryId}]',navTab.getCurrentPanel()).prop('checked',true);
		</#list>
	</@_sysDeptCategoryList>
</script>
</#if>
	</div>
</form>